package com.lagado.rrex;

public class Quantifier {

    RRex quantifiedExpression;

    Quantifier(RRex quantifiedExpression) {
        this.quantifiedExpression = quantifiedExpression;
    }

    public RRex Exactly(int timesToRepeat) {
        quantifiedExpression.add("{" + timesToRepeat + "}");
        return quantifiedExpression;
    }

    public RRex ZeroOrMore() {
        quantifiedExpression.add("*");
        return quantifiedExpression;
    }

    public RRex OneOrMore() {
        quantifiedExpression.add("+");
        return quantifiedExpression;
    }

    public RRex Optional() {
        quantifiedExpression.add("?");
        return quantifiedExpression;
    }

    public RRex AtLeast(int timesToRepeat) {
        quantifiedExpression.add("{" + timesToRepeat + ",}");
        return quantifiedExpression;
    }

    public RRex AtMost(int timesToRepeat) {
        quantifiedExpression.add("{," + timesToRepeat + "}");
        return quantifiedExpression;
    }

    public RRex InRange(int minimum, int maximum) {
        quantifiedExpression.add("{" + minimum + "," + maximum + "}");
        return quantifiedExpression;
    }

    public Quantifier Lazy() {
        return new LazyQuantifier(quantifiedExpression);
    }
}
